home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / Sample Code / AppsToGo / Kibitz / Chess.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-03-24  |  7.0 KB  |  202 lines  |  [TEXT/MPS ]

  1. #ifndef __CHESS__
  2. #define __CHESS__
  3.  
  4. #ifndef __TYPES__
  5. #include <types.h>
  6. #endif
  7.  
  8. #ifndef __APPLEEVENTS__
  9. #include <AppleEvents.h>
  10. #endif
  11.  
  12. #ifndef __PRINTING__
  13. #include <Printing.h>
  14. #endif
  15.  
  16. #ifndef __SPEECH__
  17. #include "Speech.h"
  18. #endif
  19.  
  20.  
  21. #define WHITE 0
  22. #define BLACK 1
  23.  
  24. #define QSIDE 0
  25. #define KSIDE 1
  26.  
  27. #define EMPTY    0
  28. #define PAWN    1
  29. #define KNIGHT    2
  30. #define BISHOP    3
  31. #define ROOK    4
  32. #define QUEEN    5
  33. #define KING    6
  34.  
  35. #define BP PAWN            /* Black pawn    */
  36. #define BN KNIGHT        /* Black knight    */
  37. #define BB BISHOP        /* Black bishop    */
  38. #define BR ROOK            /* Black rook    */
  39. #define BQ QUEEN        /* Black queen    */
  40. #define BK KING            /* Black king    */
  41.  
  42. #define WP -PAWN        /* White pawn    */
  43. #define WN -KNIGHT        /* White knight    */
  44. #define WB -BISHOP        /* White bishop    */
  45. #define WR -ROOK        /* White rook    */
  46. #define WQ -QUEEN        /* White queen    */
  47. #define WK -KING        /* White king    */
  48.  
  49. #define OBNDS 32767        /* Out of bounds. */
  50.  
  51. #define START_IBNDS    21        /* Start of in-bounds for the board. */
  52. #define END_IBNDS    99        /* End of in-bounds for the board. */
  53.  
  54. #define BKPOS    25
  55. #define WKPOS    95
  56.  
  57. #define kGameContinues    0
  58. #define kYouWin            1
  59. #define kYouLose        2
  60. #define kStalemate        3
  61. #define kDrawBy50        4
  62. #define kDrawByRep        5
  63. #define kYouWinOnTime    6
  64. #define kYouLoseOnTime    7
  65. #define kWhiteResigns    8
  66. #define kBlackResigns    9
  67. #define kDrawGame        10
  68. #define kWhiteWins        11
  69. #define kBlackWins        12
  70. #define kDrawButtonText    13
  71.  
  72. #define kMessageDoc        -1
  73.  
  74. #if defined(powerc) || defined (__powerc)
  75. #pragma options align=mac68k
  76. #endif
  77. typedef struct {
  78.     short    kingLoc;
  79.     short    kingMoves;
  80.     short    rookMoves[2];
  81. } KingInfo;
  82. #if defined(powerc) || defined(__powerc)
  83. #pragma options align=reset
  84. #endif
  85.  
  86. typedef struct {
  87.     short    moveFrom;
  88.     short    moveTo;
  89.     long    value;
  90. } MoveElement;
  91. typedef MoveElement MoveListAry[];
  92. typedef MoveListAry *MoveListPtr, **MoveListHndl;
  93.  
  94. typedef struct {
  95.     short    moveFrom;
  96.     short    moveTo;
  97.     short    pieceCaptured;
  98.     short    pieceCapturedFrom;        /* For undoing en-passant. */
  99.     short    promoteTo;                /* For undoing promotions and recording games. */
  100. } GameElement;
  101. typedef GameElement GameListAry[];
  102. typedef GameListAry *GameListPtr, **GameListHndl;
  103.  
  104. typedef struct {
  105.     GameElement    move;
  106.     short        enPasMove;
  107.     short        enPasPawnLoc;
  108. } MoveRec;
  109.  
  110. #if defined(powerc) || defined (__powerc)
  111. #pragma options align=mac68k
  112. #endif
  113. typedef struct {
  114.  
  115.     short            version;            /* The file format version.                   */
  116.  
  117.     Boolean            printRecValid;        /* True if print record has been created.  */
  118.     TPrint            print;                /* Print record for file.                   */
  119.  
  120.     short            theBoard[120];        /* The current board position.               */
  121.     KingInfo        king[2];            /* King locations and castling info.       */
  122.     short            enPasMove;            /* Where an en-passant could occur.           */
  123.     short            enPasPawnLoc;        /* Location of en-passant-capture.           */
  124.     short            arngEnPasMove;        /* Initial arranged en-pas move.           */
  125.     short            arngEnPasPawnLoc;    /* Initial arranged en-pas capture.           */
  126.     short            numLegalMoves;        /* # of moves in legal move list.           */
  127.     short            gameIndex;            /* Index into game record.                   */
  128.     short            numGameMoves;        /* Size of game record.                       */
  129.     short            myColor;            /* True if I am playing black.               */
  130.     short            startColor;            /* True if black started game.               */
  131.     short            arrangeBoard;        /* True if in arrange-board mode.           */
  132.     short            palettePiece;        /* Piece hilited in arrange-board palette. */
  133.     unsigned long    defaultTime[2];        /* Default ticks for white/black.           */
  134.     unsigned long    timeLeft[2];        /* Ticks remaining for white/black.           */
  135.     Boolean            invertBoard;        /* True, display board inverted.           */
  136.     short            endFileInfo1;        /* Above info is saved to disk.               */
  137.  
  138.     Str32            reconnectZone;        /* Zone of opponent.                       */
  139.     Str32            reconnectMachine;    /* Machine of opponent.                       */
  140.     Str255            reconnectPath;        /* Full path of opponent's copy of Kibitz. */
  141.     Str32            reconnectApp;        /* Name of opponent's copy of Kibitz.       */
  142.     Boolean            justBoardWindow;    /* Just the board shows if true.           */
  143.     Boolean            docIsTemplate;        /* Doc opens as Untitled, file closed.       */
  144.     Boolean            keepCMWhite;        /* True if computer moves white pieces.    */
  145.     Boolean            keepCMBlack;        /* True if computer moves black pieces.    */
  146.     short            endFileInfo2;        /* Above info is saved to disk.               */
  147.                                         /* Above info saved in later version.       */
  148.  
  149.     Boolean            twoPlayer;            /* True if playing over the net.           */
  150.     long            gameID_0;            /* Used to match up incoming moves.           */
  151.     long            gameID_1;            /* Used to match up incoming moves.           */
  152.     short            sendReason;            /* Reason for sending the game.               */
  153.     short            drawBtnState;        /* State of the draw button.                */
  154.     AEAddressDesc    locOfOpponent;        /* AppleEvents address of opponent.           */
  155.     short            endSendInfo;        /* Above is send game info.                   */
  156.  
  157.     short            resync;                /* Non-zero if resync needed.               */
  158.     Boolean            creator;            /* True if this guy originated game.       */
  159.     unsigned long    displayTime[2];        /* Time shown (is <= timeLeft).               */
  160.     unsigned long    freezeTime[2];        /* Time left when clock stopped.           */
  161.     unsigned long    timerRefTick;        /* Reference tick for timer.               */
  162.     unsigned long    compMoveTick;        /* Tick when computer moved last.           */
  163.     unsigned long    gotUpdateTick;        /* Tick when we received new game info.       */
  164.     Boolean            compMovesWhite;        /* True if computer moves white pieces.    */
  165.     Boolean            compMovesBlack;        /* True if computer moves black pieces.    */
  166.     Str32            opponentName;        /* User name of opponent.                   */
  167.     Str32            opponentZone;        /* Zone of opponent.                       */
  168.     Str32            opponentMachine;    /* Machine of opponent.                       */
  169.     unsigned long    timeLastReceive;    /* Time that last move/message received.   */
  170.     short            endLocalInfo;        /* Above info is for one machine only.       */
  171.  
  172.     Boolean            configColorChange;    /* True if color change has been posted.   */
  173.     short            configColor;        /* Color change value to be applied.       */
  174.     Boolean            configTimeChange;    /* True if time change has been posted.       */
  175.     unsigned long    configTime[2];        /* Time change value to be applied.           */
  176.     short            endConfigInfo;        /* Above info is config setting which will */
  177.                                         /* not be applied until a NULL event.       */
  178.  
  179.     MoveListHndl    legalMoves;            /* Handle of legal moves.                   */
  180.     GameListHndl    gameMoves;            /* Handle of game record (saved to disk).  */
  181.     TEHandle        message[2];            /* Handles to in/out messages.               */
  182.     Handle            sound;                /* Handle to recorded sound.               */
  183.     Boolean            doSpeech;
  184.     VoiceSpec        theVoice;
  185.     ControlHandle    sendMessage;        /* Handle to send button.                   */
  186.     ControlHandle    beepOnMove;            /* Handle to move-beep checkbox.           */
  187.     ControlHandle    beepOnMssg;            /* Handle to mssg-beep checkbox.           */
  188.     ControlHandle    gameSlider;            /* Handle to slider custom control.           */
  189.     ControlHandle    wbStart[2];            /* Handles to arrange board controls.       */
  190.     ControlHandle    resign;                /* Handle to resign button.                   */
  191.     ControlHandle    draw;                /* Handle to draw button.                   */
  192.     ControlHandle    record;                /* Handle to record sound button.           */
  193.     ControlHandle    sendSnd;            /* Handle to send sound button.               */
  194.     short            endControls;        /* Above info is reference to controls.       */
  195.  
  196. } TheDoc, *TheDocPtr, **TheDocHndl;
  197. #if defined(powerc) || defined(__powerc)
  198. #pragma options align=reset
  199. #endif
  200.  
  201. #endif
  202.